/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-09-19
 * Time: 17:12
 */
public class find_Min {
    public static int findMin(int[] nums) {


        int left = 0, right = nums.length - 1;

        int x=nums[right];
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] >= x) {
                left = mid+1;
            } else {
                right = mid;
            }
        }

        return nums[right];
    }

    public static void main(String[] args) {
        int[] nums = new int[]{4, 5, 6, 7, 0, 1, 2};
        System.out.println(findMin(nums));
    }
}
